# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libcdr
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.1.6
pkgrel=3
pkgdesc="libcdr is a library and a set of tools for reading and converting binary files produced by Corel DRAW (mingw-w64)"
arch=('any')
license=('MPL2')
url="https://wiki.documentfoundation.org/DLP/Libraries/libcdr"
options=('staticlibs' 'strip')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-boost"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-doxygen"
             "${MINGW_PACKAGE_PREFIX}-cppunit")
depends=("${MINGW_PACKAGE_PREFIX}-icu"
         "${MINGW_PACKAGE_PREFIX}-lcms2"
         "${MINGW_PACKAGE_PREFIX}-librevenge"
         "${MINGW_PACKAGE_PREFIX}-zlib")
source=("https://dev-www.libreoffice.org/src/${_realname}/${_realname}-${pkgver}.tar.xz")
sha256sums=('01cd00b04a030977e544433c2d127c997205332cd9b8e35ec0ee17110da7f861')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
}

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir -p ${srcdir}/build-${MINGW_CHOST} && cd "${srcdir}/build-${MINGW_CHOST}"
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --enable-static \
    --disable-silent-rules

  make -j1
}

check() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make -k check || true
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make -j1 DESTDIR="${pkgdir}" install
}
